import requests
import os

def test_png_upload():
    """测试PNG图片上传和分析"""
    if not os.path.exists('1.png'):
        print("❌ 测试文件 1.png 不存在")
        return False
    
    try:
        with open('1.png', 'rb') as f:
            files = {'file': ('1.png', f, 'image/png')}
            response = requests.post('http://localhost:8080/analyze_single', files=files)
        
        print(f"状态码: {response.status_code}")
        
        if response.status_code == 200:
            result = response.json()
            print("✅ PNG图片分析成功!")
            print(f"文件类型: {result.get('文件类型')}")
            print(f"是否可以作为证据: {result.get('是否可以作为证据')}")
            print(f"文件内容: {result.get('文件内容')[:200]}...")
            return True
        else:
            print(f"❌ 分析失败: {response.text}")
            return False
            
    except Exception as e:
        print(f"❌ 测试失败: {e}")
        return False

if __name__ == "__main__":
    print("🧪 测试PNG图片格式支持...")
    test_png_upload()